<?php

class foo {
    public function __destruct () {
        echo "Destructor called!\n";
    }
}

$arr = array();
$arr['foo'] = new foo;

$shutdown = function () use (&$arr) {
    echo "Shutdown function called!\n";
    trigger_error('Error', E_USER_NOTICE);
    unset($arr['foo']);
    gc_collect_cycles();
    var_dump($arr);
};

register_shutdown_function($shutdown);
pcntl_signal(SIGINT, $shutdown);

//fatal_error();
sleep(10);

echo "Done\n";

// vim: ts=4 et ai

